package com.qf.controller;

import com.qf.model.Address;
import com.qf.model.Car;
import com.qf.model.User;
import com.qf.service.AddressService;
import com.qf.service.impl.AddressServiceImpl;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.List;

@WebServlet("/address")
public class AddressController extends BaseServlet{
    //我就加了个注释1111
    AddressService addressService=new AddressServiceImpl();
    public String getSelfInfo(HttpServletRequest request, HttpServletResponse response){
        HttpSession session = request.getSession();
        Object user = session.getAttribute("loginUser");
        if(user==null){
            return "REDIRECT:login.jsp";
        }

        int uid=((User)user).getId();

        //还要根据uid拿到地址集合
        List<Address> addressList=addressService.getAllAddress(uid);
        request.setAttribute("addressList",addressList);



        return "FORWARD:self_info.jsp";
    }
}
